package com.xmmj.common.room.dao

import androidx.room.*
import com.xmmj.common.room.entity.HistoryBean

/**
 * 搜索历史的工具类
 */
@Dao
interface HistoryDao {
    @Insert
    suspend fun insert(vararg record: HistoryBean)

    @Insert
    suspend fun insert(recordList: List<HistoryBean>)

    @Delete
    suspend fun delete(vararg record: HistoryBean): Int

    @Delete
    suspend fun delete(recordList: List<HistoryBean>): Int

    @Update
    suspend fun update(vararg record: HistoryBean): Int

    @Update
    suspend fun update(recordList: List<HistoryBean>): Int

    @Query("SELECT * FROM history ORDER BY city ASC")
    suspend fun searchAll(): List<HistoryBean>

    @Query("SELECT * FROM history WHERE city =:city")
    suspend fun searchByCityName(city: String): List<HistoryBean>

    @Query("DELETE FROM history")
    suspend fun deleteAll()
}